package com.muyu.danmo.controller;


import com.muyu.common.core.domain.Result;
import com.muyu.common.core.utils.poi.ExcelUtil;
import com.muyu.common.core.web.controller.BaseController;
import com.muyu.common.core.web.page.TableDataInfo;
import com.muyu.common.log.annotation.Log;
import com.muyu.common.log.enums.BusinessType;
import com.muyu.common.security.utils.SecurityUtils;
import com.muyu.common.system.domain.LoginUser;
import com.muyu.danmo.domain.DanmoInformationFlagship;
import com.muyu.danmo.service.IDanmoInformationFlagshipService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 个人信息名家推荐店铺Controller
 * 
 * @author yangle
 * @date 2024-12-17
 */
@RestController
@RequestMapping("/danmoInformationFlagship")
public class DanmoInformationFlagshipController extends BaseController
{
    @Autowired
    private IDanmoInformationFlagshipService danmoInformationFlagshipService;

    /**
     * 查询个人信息名家推荐店铺列表
     */
//    @RequiresPermissions("system:danmoInformationFlagship:list")
    @GetMapping("/list")
    public Result<TableDataInfo<DanmoInformationFlagship>> list(DanmoInformationFlagship danmoInformationFlagship)
    {
        startPage();
        List<DanmoInformationFlagship> list = danmoInformationFlagshipService.selectDanmoInformationFlagshipList(danmoInformationFlagship);
        return getDataTable(list);
    }

    /**
     * 导出个人信息名家推荐店铺列表
     */
//    @RequiresPermissions("system:danmoInformationFlagship:export")
    @Log(title = "个人信息名家推荐店铺", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DanmoInformationFlagship danmoInformationFlagship)
    {
        List<DanmoInformationFlagship> list = danmoInformationFlagshipService.selectDanmoInformationFlagshipList(danmoInformationFlagship);
        ExcelUtil<DanmoInformationFlagship> util = new ExcelUtil<DanmoInformationFlagship>(DanmoInformationFlagship.class);
        util.exportExcel(response, list, "个人信息名家推荐店铺数据");
    }

    /**
     * 获取个人信息名家推荐店铺详细信息
     */
//    @RequiresPermissions("system:danmoInformationFlagship:query")
    @GetMapping(value = "/{id}")
    public Result getInfo(@PathVariable("id") Long id)
    {
        return success(danmoInformationFlagshipService.selectDanmoInformationFlagshipById(id));
    }

    /**
     * 新增个人信息名家推荐店铺
     */
//    @RequiresPermissions("system:danmoInformationFlagship:add")
    @Log(title = "个人信息名家推荐店铺", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    public Result add(@RequestBody DanmoInformationFlagship danmoInformationFlagship)
    {
        LoginUser loginUser = SecurityUtils.getLoginUser();
        if (loginUser==null){
            return Result.notLoggedIn("请登录");
        }
        danmoInformationFlagship.setUserId(loginUser.getUserid());
        return danmoInformationFlagshipService.insertDanmoInformationFlagship(danmoInformationFlagship);
    }

    /**
     * 修改个人信息名家推荐店铺
     */
//    @RequiresPermissions("system:danmoInformationFlagship:edit")
    @Log(title = "个人信息名家推荐店铺", businessType = BusinessType.UPDATE)
    @PutMapping
    public Result edit(@RequestBody DanmoInformationFlagship danmoInformationFlagship)
    {
        return danmoInformationFlagshipService.updateDanmoInformationFlagship(danmoInformationFlagship);
    }

    /**
     * 删除个人信息名家推荐店铺
     */
//    @RequiresPermissions("system:danmoInformationFlagship:remove")
    @Log(title = "个人信息名家推荐店铺", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public Result remove(@PathVariable Long[] ids)
    {
        return danmoInformationFlagshipService.deleteDanmoInformationFlagshipByIds(ids);
    }
}
